#include <iostream>
#include <cstdio>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

const std::string myenv="HELLO=AAAAAAAAAAAAAAAAAAAA";

int main()
{   
    putenv((char*)myenv.c_str());
    pid_t id = fork();
    if(id == 0)
    {
        char *const argv[] = {
            (char*)"other",
            nullptr
        };

        char *const env[] = {
            (char*)"HELLO=linux",
            (char*)"HELLO1=linux1",
            (char*)"HELLO2=linux2",
            (char*)"HELLO3=linux3"
        };

        execvp("./other", argv );
        exit(1);
    }

    pid_t rid = waitpid(id, nullptr, 0);
    if(rid > 0)
    {
        printf("等待子进程成功!\n");
    }
    return 0;
}
